function zan_blog(Id)  // 删除动态
{
    var blog_id = Id;
    $.ajax({
        data: {
            blog_Id: blog_id
        },
        type: 'POST',
        url: 'zan_blog.html',
        success: function (data) {
            if (data.status == 'success') {
                layer.msg('赞！');
                location.reload();
            } else {
                layer.msg('出错了');
            }
        },
        error: function () {
            layer.msg('出错了');
        }
    })
}

function zan_comment(Id)  // 删除动态
{
    var comment_id = Id;
    $.ajax({
        data: {
            comment_Id: comment_id
        },
        type: 'POST',
        url: 'zan_comment.html',
        success: function (data) {
            if (data.status == 'success') {
                layer.msg('赞！');
                location.reload();
            } else {
                layer.msg('出错了');
            }
        },
        error: function () {
            layer.msg('出错了');
        }
    })
}

function delete_blog(Id)  // 删除动态
{
    var blog_id = Id;
    $.ajax({
        data: {
            blog_Id: blog_id
        },
        type: 'POST',
        url: 'delete_blog.html',
        success: function (data) {
            if (data.status == 'success') {
                layer.msg('删除成功');
                location.reload();
            } else {
                layer.msg(data.msg);
            }
        },
        error: function () {
            layer.msg('删除失败');
        }
    })
}

function delete_comment(Id)  // 删除动态
{
    var comment_id = Id;
    $.ajax({
        data: {
            comment_Id: comment_id
        },
        type: 'POST',
        url: 'delete_comment.html',
        success: function (data) {
            if (data.status == 'success') {
                layer.msg('删除成功');
                location.reload();
            } else {
                layer.msg(data.msg);
            }
        },
        error: function () {
            layer.msg('删除失败');
        }
    })
}

function show(Id) {
    var $target = $('#text' + Id);
    if ($target.is(':hidden') == true) {
        $target.attr('hidden', false);
    } else {
        $target.attr('hidden', true);
    }
}

function send_comment(Id) {
    var $comment = $('#comment' + Id);
    var info = $comment.val();
    var blog_id = Id;
    $.ajax({
        data: {
            blog_Id: blog_id,
            info: info
        },
        type: 'POST',
        url: 'add_comment.html',
        success: function (data) {
            if (data.status == 'success') {
                layer.msg('评论成功');
                $comment.val("");
                location.reload();
            } else {
                layer.msg('评论失败');
            }
        },
        error: function () {
            layer.msg('评论失败');
        }
    })

}

$('#add').on('click', function () {
    layer.open({
        type: 2,
        title: '发表动态',
        shadeClose: false,
        shade: 0.8,
        area: ['70%', '90%'],
        content: 'add.html',
        end: function () {
            location.reload();
        }
    })
})